package com.leilbase.authshiro.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
import com.leilbase.authshiro.auth.entity.User;
import com.leilbase.authshiro.auth.mapper.UserMapper;
import com.leilbase.authshiro.auth.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Leil
 * @since 2019-07-23
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    /**
     * 通过名称获取用户角色和权限
     * @param name  用户名称
     * @return      角色和权限的map
     */
    public List<Map<String, Object>> listUserRolePermissionMapsByName(String name) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", name);
        List<Map<String, Object>> mapList = baseMapper.selectUserRolePermissionMaps(queryWrapper);
        return mapList;
    }

}
